<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!doctype html>
<html  class="x-admin-sm">
<head>
	<meta charset="UTF-8">
	<title>管理登录</title>
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/login.css">
	  <link rel="stylesheet" href="./css/index.css">
      <!-- 	  引入的JQuery.js -->
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
   <script src="https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>


</head>
<body class="login-bg">
    
    <div class="login layui-anim layui-anim-up">
        <div class="message">管理登录</div>
        <div id="darkbannerwrap"></div>
        
        <!-- 在当前路径"上下文/back/login.jsp"请求控制器地址"上下文/login",地址注意需要回到上一级-->
        <form method="post" class="layui-form" action="../../LoginServlet" id="login" onsubmit="return a()">
        	<!-- 隐藏域 -->
        	<input type="hidden" name="role" value="1">
            <input name="mobile" placeholder="手机号"  type="text" lay-verify="required" class="layui-input" id="mobile">
            <hr class="hr15">
            <input name="password" lay-verify="required" placeholder="密码"  type="password" class="layui-input" id="password" >
            <hr class="hr15">
            <input name="remember" lay-verify="required"   type="checkbox" style="display:inline-block" id="rememberme">  记住密码
            <hr class="hr15">
            <input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
            <hr class="hr20" >
        </form>
    </div>
    
<script type="text/ecmascript" src="./js/md5.min.js"></script>
<script type="text/javascript">


//         if($("#password").val().length != 32){
// 			 var hash = md5($("#password").val());
// 			 $("#md5").val(hash);
// 		}
        
       function a(){
    	   if($("#password").val().length != 32){
    		   $("#password").val(md5($("#password").val()));
    	   }
    	   return true;
    	   
      }
        
		

</script>
    
    <script>
    $(document).ready(function(){
    	 let k3 = $.cookie('rememberMe');
    	
    	if(k3!=null){
    		let collection = k3.split("=");	
        	$("#mobile").val(collection[0]);	
        	$("#password").val(collection[1]);       		
        	$("#rememberme").prop("checked",true);	
        	}
        	
     	  // 当用户访问登录页面的时候，输入用户名失去焦点如果有对应的cookie则显示在指定密码位置上,并设置复选框为选中状态
  	 	 $("input[name='mobile']").on("input",function(){
  		  // 清空密码和取消选中
  		  $("input[name='password']").val("");
  		  $("input[name='remember']").prop("checked",false);
  		  
  		  // 获取输入的手机号
  		  let mobile = $(this).val();
  		  // 和cookie中rememberMe的value值前半部分手机号进行对比
  		  let rememberMe = $.cookie('rememberMe');  
  		  if(rememberMe != null){
  			  let vs = rememberMe.split("="); // ["手机号","密码"]
  			  if(vs[0] == mobile){
  				  // 填充密码和把复选框选中
  				  $("input[name='password']").val(vs[1]);
  				  $("input[name='remember']").prop("checked",true);
  			  }
  		  }
  		  
  	  }) 

    	
    	
    });
    
    
    
    </script>
      

    <script>
    /* 
        $(function  () {
         layui.use('form', function(){
              var form = layui.form;
              // layer.msg('玩命卖萌中', function(){
              //   //关闭后的操作
              //   });
              //监听提交
              form.on('submit(login)', function(data){
                // alert(888)
                layer.msg(JSON.stringify(data.field),function(){
                    location.href='index.html'
                });
                return false;
              });
            }); 
        })
      */
      // 通过el表达式获取请求参数
      let message = "${param.message}";
      if(message != ""){
    	  // 提示登录失败
    	  layui.use('layer', function(){
    		  var layer = layui.layer;
    		  layer.msg('用户名或密码错误');
    		});   
    	  
      }
      
      // 通过js或jQuery读取cookie做填充
    </script>
    <!-- 底部结束 -->
    <script>
    //百度统计可去掉
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
      var s = document.getElementsByTagName("script")[0]; 
      s.parentNode.insertBefore(hm, s);
    })();
    </script>
</body>
</html>